/*
 * @Author: szx
 * @Date: 2022-03-21 15:26:59
 * @LastEditTime: 2022-03-21 15:29:59
 * @Description:
 * @FilePath: \leetcode\剑指offer\21\21.js
 */
/**
 * @param {number[]} nums
 * @return {number[]}
 */
var exchange = function (nums) {
    let i = 0,
        j = nums.length - 1;
    while (i < j) {
        if (nums[j] & 1) {
            [nums[i], nums[j]] = [nums[j], nums[i]];
            i++;
        } else j--;
    }
    return nums;
};
console.log(exchange([1, 2, 3, 4]));
